package com.rsk.dao;


import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.rsk.entity.SysDept;


@Repository
public interface SysDeptRepository extends JpaRepository<SysDept, Long>,JpaSpecificationExecutor<SysDept>,Serializable {
	
	@Modifying
	@Query(value = "update sys_depts set dept_name = ?2, operator_user =?3, operator_time = NOW() where id =?1", nativeQuery = true)
	public int updateSysDept(Long id, String deptName, Long operatorUser);
	
	@Modifying
	@Query(value = "update sys_depts set is_del = 1, operator_user =?2, operator_time = NOW() where id =?1", nativeQuery = true)
	public int delSysDept(Long id, Long operatorUser);
	
	@Query(value = "select * from sys_depts where dept_code =?1 and is_del = 0", nativeQuery = true)
	public List<Map<String, Object>> selectSysDeptByDeptCode(String deptCode);

}
